package com.example.blog.module.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.blog.module.entity.ArticleTag;
import com.example.blog.module.mapper.ArticleTagMapper;
import com.example.blog.module.service.ArticleTagService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zjx
 * @since 2022-11-23
 */
@Service
@RequiredArgsConstructor
public class ArticleTagServiceImpl extends ServiceImpl<ArticleTagMapper, ArticleTag> implements ArticleTagService {

    private final ArticleTagMapper articleTagMapper;

    @Override
    public List<Long> getIdsByArticleId(Long articleId) {
        QueryWrapper<ArticleTag> wrapper=new QueryWrapper<>();
        wrapper.eq("article_id",articleId);
        List<ArticleTag> articleTags=articleTagMapper.selectList(wrapper);
        List<Long> ids=new ArrayList<>();
        for (ArticleTag at:articleTags) {
            ids.add(at.getTagId());
        }
        return ids;
    }
}
